home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual dBase v5.5 / MUSIC1.PAK / SEARCH.WFM < prev    next >
Encoding:
Text File  |  1995-07-18  |  7.3 KB  |  239 lines

  1. *******************************************************************************
  2. *  PROGRAM:      Search.wfm
  3. *
  4. *  WRITTEN BY:   Borland Samples Group
  5. *
  6. *  DATE:         1/94
  7. *
  8. *  UPDATED:      5/95
  9. *
  10. *  REVISION:     $Revision:   1.28  $
  11. *
  12. *  VERSION:      Visual dBASE
  13. *
  14. *  DESCRIPTION:  This form allows setting a filter on the items currently
  15. *                viewed.  It allows you to create a combination filter based
  16. *                on the artist, title, price, release date, and media type
  17. *                of the available items from the Musical Methods store.
  18. *
  19. *  PARAMETERS:   None
  20. *
  21. *  CALLS:        Music.cc      (for custom pushbuttons)
  22. *                Music.prg     (procedure file)
  23. *
  24. *  USAGE:        DO Search.wfm  && or
  25. *
  26. *                local f
  27. *                set procedure to Search.wfm
  28. *                f = new SearchForm()
  29. *                f.ReadModal()
  30. *******************************************************************************
  31. #include <Messdlg.h>
  32. #include "Music.h"
  33. set talk off
  34. set ldcheck off
  35.  
  36. ** END HEADER -- do not remove this line*
  37. * Generated on 06/19/94
  38. *
  39. parameter bModal
  40. local f
  41. f = new SEARCHFORM()
  42. if (bModal)
  43.    f.mdi = .F. && ensure not MDI
  44.    f.ReadModal()
  45. else
  46.    f.Open()
  47. endif
  48. CLASS SEARCHFORM OF FORM
  49.    Set Procedure to Music.cc Additive
  50.    this.MousePointer =          1
  51.    this.ColorNormal = "W"
  52.    this.Width =         60.35
  53.    this.Top =          6.18
  54.    this.Text = "Search"
  55.    this.Left =         23.29
  56.    this.OnSelection = CLASS::ONSELECTION
  57.    this.Height =          8.71
  58.    this.Minimize = .F.
  59.    this.Maximize = .F.
  60.    this.OnOpen = CLASS::ONOPEN
  61.    this.OnClose = CLASS::ONCLOSE
  62.    this.HelpFile = ""
  63.    this.HelpId = ""
  64.  
  65.    DEFINE RECTANGLE SEARCHRECT OF THIS;
  66.        PROPERTY;
  67.          ColorNormal "w*/r",;
  68.          Width         57.97,;
  69.          Top          0.50,;
  70.          Text "",;
  71.          Left          1.19,;
  72.          Height          3.79,;
  73.          Border .T.,;
  74.          BorderStyle          1
  75.  
  76.    DEFINE NORMALTEXT FIELDTEXT OF THIS;
  77.        PROPERTY;
  78.          FontBold .F.,;
  79.          Alignment          5,;
  80.          ColorNormal "w*/r",;
  81.          Width         9.35,;
  82.          Top          1.01,;
  83.          Text "Field:",;
  84.          Left          1.87,;
  85.          Height          1.26,;
  86.          Border .F.
  87.  
  88.    DEFINE COMBOBOX FIELDCOMBO OF THIS;
  89.        PROPERTY;
  90.          Width         27.20,;
  91.          DataSource "STRUCTURE",;
  92.          Top          1.00,;
  93.          ID        800,;
  94.          Left         11.90,;
  95.          Value "",;
  96.          Height          1.18,;
  97.          Style          2,;
  98.          HelpFile "Music.hlp",;
  99.          HelpID "Search Field",;
  100.          StatusMessage "Select a field to search for.  Press F1 for Help."
  101.  
  102.    DEFINE NORMALTEXT VALUETEXT OF THIS;
  103.        PROPERTY;
  104.          FontBold .F.,;
  105.          Alignment          5,;
  106.          ColorNormal "w*/r",;
  107.          Width         9.35,;
  108.          Top          2.47,;
  109.          Text "Value:",;
  110.          Left          1.87,;
  111.          Height          1.24,;
  112.          Border .F.
  113.  
  114.    DEFINE NORMALENTRY VALUEENTRY OF THIS;
  115.        PROPERTY;
  116.          ColorNormal "R/W",;
  117.          StatusMessage "Enter a value to search for.  Press F1 for help.",;
  118.          Width         45.90,;
  119.          Top          2.47,;
  120.          Left         11.90,;
  121.          Value "                    ",;
  122.          Height          1.24,;
  123.          HelpFile "Music.hlp",;
  124.          HelpID "Search Value",;
  125.          Border .T.,;
  126.          ColorHighLight "R/W*",;
  127.          Enabled .T.,;
  128.          Function "!"
  129.  
  130.    DEFINE IMAGE LOGOIMAGE OF THIS;
  131.        PROPERTY;
  132.          Alignment          2,;
  133.          Width         10.71,;
  134.          DataSource "FILENAME SMLMUSIC.BMP",;
  135.          Top          4.55,;
  136.          Left          1.19,;
  137.          Height          3.79
  138.  
  139.    DEFINE OKMBUTTON SEARCHOKBUTTON OF THIS;
  140.        PROPERTY;
  141.          Width         14.11,;
  142.          Top          6.50,;
  143.          Left         28.56,;
  144.          Height          1.50
  145.  
  146.    DEFINE CANCELMBUTTON SEARCHCANCELBUTTON OF THIS;
  147.        PROPERTY;
  148.          Group .F.,;
  149.          Width         14.11,;
  150.          Top          6.50,;
  151.          ID          0,;
  152.          Left         44.20,;
  153.          Height          1.50
  154.  
  155.    ****************************************************************************
  156.    procedure OnOpen
  157.    ****************************************************************************
  158.    set procedure to music.prg additive
  159.    form.tempIsOpen = .F.                   && necessary for knowing if temp
  160.                                            && table is in use at closing time
  161.    *******************************************************************************
  162.    procedure OnSelection
  163.  
  164.    * Search for the record where searchField = searchValue
  165.    * This procedure is called when the OK button is pressed in the Search form.
  166.    *******************************************************************************
  167.    param  controlId
  168.    private curTable,formName,field,value,searchForm,foundRecord,saveFilt,;
  169.               tagNo,keyTagno,closeForm
  170.  
  171.    field = ALLTRIM(this.fieldCombo.value)            && searchField
  172.    value = ALLTRIM(this.valueEntry.value)            && searchValue
  173.    closeForm = .F.
  174.    saveFilt = setto("filter")
  175.    set filter to
  176.    curTable = alias()
  177.    do case
  178.       case controlId = 0    && Cancel was selected.  Don't do anything
  179.          closeForm = .T.
  180.       case empty(field)
  181.          AlertMessage("No field was selected. Try again.","Alert")
  182.       case empty(value)
  183.          AlertMessage("No value was specified. Try again.", "Alert")
  184.       otherwise
  185.          if .not. form.tempIsOpen
  186.             use (curTable) in select() again alias temp
  187.             form.tempIsOpen = .T.
  188.          endif
  189.          select temp
  190.          set filter to &saveFilt && Same filter as main table
  191.          go top
  192.          *** convert value to type of key()
  193.          value = iif(type(field) $ "NF",val(value),value)
  194.          tagNo = tagno(field)
  195.          keyTagNo = key(tagNo)
  196.          * Tags based on single field have field name
  197.          if tagNo > 0 .and. ;
  198.             (keyTagNo = field .or. upper(keyTagNo) = "UPPER(" + field)
  199.                set order to &field
  200.                seek value
  201.          else
  202.             locate for &field = value
  203.          endif
  204.          *** convert back to character type if necessary
  205.          value = ALLTRIM(this.valueEntry.value)
  206.          foundRecord = recno()
  207.          select &curTable
  208.          if .not. found("temp")
  209.             if ConfirmationMessage(FormatStr("%1 %2 not found. Continue Search?",;
  210.                                              proper(field),value),;
  211.                                     "Confirmation") = NO
  212.                use in temp
  213.                form.tempIsOpen = .F.
  214.                closeForm = .T.
  215.             endif
  216.          else
  217.             go foundRecord
  218.             set message to FormatStr("%1 %2 was found.", proper(field),value)
  219.             use in temp
  220.             form.tempIsOpen = .F.
  221.             closeForm = .T.
  222.          endif
  223.    endcase
  224.    if closeForm
  225.       form.Close()
  226.    endif
  227.  
  228.    *******************************************************************************
  229.    procedure OnClose
  230.    *******************************************************************************
  231.    if form.tempIsOpen
  232.       use in temp
  233.    endif
  234.  
  235. ENDCLASS
  236.  
  237.  
  238.  
  239.